#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
void func2(int arr1[], int arr2[],int n,int m)
{
    int i = 0, j = 0;
    while (i<n&&j<m)
    {
        if (arr1[i] >= arr2[j])
        {
            printf("%d ", arr2[j]);
            j++;
        }
        else
        {
            printf("%d ", arr1[i]);
            i++;
        }
    }
    if (i==n)
    {
        while (j!=m)
        {
            printf("%d ", arr2[j]);
            j++;
        }
    }
    else {
        while (i!=n)
        {
            printf("%d ", arr1[i]);
            i++;
        }
    }
}
void func1(int arr[],int n)
{
    int i, j;
    for (i = 0; i < n - 1; i++)
    {
        for (j = 0; j < n - 1; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                int tmp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = tmp;
            }
        }
    }
}
int main() {
    int n, m;
    int arr1[10], arr2[10];
    scanf("%d%d", &n, &m);
    int i, j;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
    }
    for (i = 0; i < m; i++)
    {
        scanf("%d", &arr2[i]);
    }
    func1(arr1,n);
    func1(arr2,m);
   func2(arr1, arr2,n,m);
    return 0;
}